<?php

namespace Drupal\shushengyuan\Schemas;

use Drupal\points\Entity\Points;

/**
 * @OA\Schema(
 *   schema="PointItem",
 *   type="object",
 *   description="PointItem"
 * )
 */
class PointItem extends AbstractBaseModel {

  protected function getEntityType() {
    return 'points';
  }

  protected function setValue() {
    if ($this->entity instanceof Points) {
      $value = [
        /**
         * @OA\Property(
         *   property="point",
         *   type="integer",
         *   description="积分数量",
         * ),
         */
        'point' => (int) $this->entity->point,
        /**
         * @OA\Property(
         *   property="info",
         *   type="string",
         *   description="获取描述",
         * ),
         */
        'info' => (string) $this->entity->description,
        /**
         * @OA\Property(
         *   property="created",
         *   type="string",
         *   description="获取时间",
         * ),
         */
        'created' => $this->formatDate($this->entity->created, 'm月d号 H:i'),
      ];
      $this->merge($value);
    }
  }
}
